import Vue from 'vue'
import Router from 'vue-router'

const appview = () => import('@/components/appview')
const login = () => import('@/pages/login')
const home = () => import('@/pages/home')
const adManage = () => import('@/pages/adManage/adManage')
const adPosition = () => import('@/pages/adManage/adPosition')
const adList = () => import('@/pages/adManage/adList')
const editAdvManage = () => import('@/pages/adManage/editAdvManage')
const newAdvManage = () => import('@/pages/adManage/newAdvManage')
const menuManage = () => import('@/pages/menuManage')

const page404 = () => import('@/components/page404')

Vue.use(Router)

export default new Router({
  mode: 'hash',
  routes: [
    {
      path: '/',
      component: appview,
      redirect: '/home',
      children: [
        {
          path: '/home',
          component: home
        },
        {
          path: '/adManage',
          component: adManage,
          children: [
            { path: '/', component: adList, meta: ['广告管理', '广告设置'] },
            { path: '/adManage/edit/:id', component: editAdvManage },
            { path: '/adManage/add', component: newAdvManage }
          ]
        },
        {
          path: '/adPosition',
          component: adPosition,
          meta: ['广告位设置']
        },
        {
          path: '/menuManage',
          component: menuManage,
          meta: ['菜单管理']
        }
      ]
    },
    {
      path: '/login',
      component: login,
      name: '登录'
    },
    {
      path: '*',
      component: page404
    }
  ]
})
